#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright [Gtlions Lai].
# Create Date:
# Update Date:
"""summarization ahout this script.

detail ahout this script

   Class(): summarization about Class
   ...
   function(): summarization about function
   ...
"""
__authors__ = '"Gtlions Lai" <gtlions.l@qq.com>'

import time
import threading
import os

def do(name):
    os.system("""psql gtlions -c 'select now();'""")

def music(name, times, interval):
    for i in range(times):
        print 'Thread:[' + name + '], No:[' + str(times) + '], Now is:' + time.ctime() + '\n'
        time.sleep(interval)


def threaddone():
    threads = []
    t1 = threading.Thread(target=do, args=('a',))
    t2 = threading.Thread(target=do, args=('b',))
    t3 = threading.Thread(target=do, args=('c',))
    t4 = threading.Thread(target=do, args=('d',))
    t5 = threading.Thread(target=do, args=('e',))
    t6 = threading.Thread(target=do, args=('f',))
    t7 = threading.Thread(target=do, args=('g',))
    threads.append(t1)
    threads.append(t2)
    threads.append(t3)
    threads.append(t4)
    threads.append(t5)
    threads.append(t6)
    threads.append(t7)
    # t1 = threading.Thread(target=music, args=(u'十年', 1, 3,))
    # threads.append(t1)
    # t2 = threading.Thread(target=music, args=(u'十年2014', 1, 6,))
    # threads.append(t2)

    for t in threads:
        t.setDaemon(True)
        t.start()
    t.join()
#music('a',2,2)

threaddone()